package com.atguigu.gmall.product.service.impl;

import com.atguigu.gmall.product.mapper.BaseCategory2Mapper;
import com.atguigu.gmall.product.model.BaseCategory2;
import com.atguigu.gmall.product.service.BaseCategory2Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: atguigu
 * @create: 2023-02-20 15:42
 */
@Service
public class BaseCategory2ServiceImpl extends ServiceImpl<BaseCategory2Mapper, BaseCategory2> implements BaseCategory2Service {

    /**
     * 根据一级分类ID查询该分类下二级分类列表
     * @param category1Id 一级分类ID
     * @return
     */
    @Override
    public List<BaseCategory2> getCategory2(Long category1Id) {
        //SELECT * FROM base_category2 where category1_id = 2 and is_deleted = '0'
        LambdaQueryWrapper<BaseCategory2> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BaseCategory2::getCategory1Id, category1Id);
        queryWrapper.eq(BaseCategory2::getIsDeleted, '0');
        return this.list(queryWrapper);
    }
}
